<% layout('/layout/default.html', {title: '机构管理', libs: ['dataGrid']}){ %>
<div class="main-content">
		<div class="card-header">
			<i class="fa fa-sitemap"></i> 机构管理
			<div class="header-tools float-right">
				<a href="#" class="btn btn-default btn-sm"  id="btnRefreshTree" title="刷新"><i class="fa fa-refresh"></i> 刷新</a>
				<a href="#" class="btn btn-default btn-sm" id="btnExpandTreeNode" title="展开全部"><i class="fa fa-angle-double-down"></i> 展开</a>
				<a href="#" class="btn btn-default btn-sm" id="btnCollapseTreeNode" title="折叠全部"><i class="fa fa-angle-double-up"></i> 折叠</a>
				<% if(hasPermi('sys:office:edit')){ %>
					<a href="/sys/office/form" class="btn btn-default btn-sm btnTool" title="添加机构"><i class="fa fa-plus"></i> 添加机构</a>
				<% } %>
			</div>
		</div>
		<div class="container-fluid">
			<form id="searchForm" action="${ctx}/sys/office/listData" class="form-inline d-none">
				<div class="form-group">
					<button type="submit" class="btn btn-success btn-sm ">查询</button>
					<button type="reset" class="btn btn-default btn-sm">重置</button>
				</div>
			</form>			
			<table id="dataGrid"></table>
		</div>
</div>
<% } %>
<script>
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{header:'机构名称', name:'name', index:'a.name', width:150, align:"left"},
			{header:'归属区域', name:'area.name', index:'ar.name', width:80, align:"center"},
			{header:'机构编码', name:'code', index:'a.code', width:80, align:"center"},
			{header:'机构类型', name:'type', index:'a.type', width:80, align:"center", formatter: function(val, obj, row, act){
					return js.transDictLabel(${@DictUtils.getDictListJson('sys_office_type')}, val, '');
				}},
			{header:'备注', name:'remarks', index:'a.remarks', width:80, align:"center"},
			{header:'操作', name:'actions', width:70,align:"center", sortable:false, title:false, formatter: function(val, obj, row, act){
					var actions = [];
				<% if(hasPermi('sys:office:edit')){ %>
						actions.push('<a href="/sys/office/form?id='+row.id+'" class="btnList" title="修改机构信息"><i class="fas fa-pencil-alt"></i></a>');
						actions.push('<a href="${ctx}/sys/office/delete?id='+row.id+'" class="btnList" title="删除机构" data-confirm="要删除该机构及所有子机构项吗？"><i class="far fa-trash-alt"></i></a>');
						actions.push('<a href="/sys/office/form?parentId='+row.id+'" class="btnList" title="添加下级机构"><i class="fa fa-plus-square"></i></a>');
					<% } %>
					return actions.join('');
				}}
		],
		treeGrid: true,
		defaultExpandLevel: 0,
		expandNodeClearPostData: 'name',
		treeIcons : {
			plus: "ui-icon-circlesmall-plus",
			minus: "ui-icon-circlesmall-minus",
			leaf : "ui-icon-radio-off"
		},
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});
</script>